package com.esd.controller.csair;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.esd.csair.CS;
import com.esd.csair.Csair;
import com.esd.csair.CsairImpl;
import com.esd.csair.CsairReturnValue;
import com.esd.csair.Passenger;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * 
 * 单程模块/往返模块
 * 
 * @author snailzhang
 * @date 2017年7月20日
 *
 */
@Controller
@RequestMapping(value = "cs")
public class CSBuyTicketController {
	
	private static Logger log = Logger.getLogger(CSBuyTicketController.class);
	/**
	 * 加载单程航班查询页
	 * 
	 * @param c1
	 * @param c2
	 * @param date
	 * @param number1
	 * @param number2
	 * @param number3
	 * @return
	 */
	@RequestMapping(value = "flightQuery", method = RequestMethod.GET)
	public ModelAndView query(HttpSession session, HttpServletRequest request) {
		log.info("===================加载航班查询页==================");
		String c1 = request.getParameter("c1");
		String c2 = request.getParameter("c2");
		String date = request.getParameter("date");
		// log.info(request.getParameter("number1"));
		int number1 = Integer.valueOf(request.getParameter("number1"));
		int number2 = Integer.valueOf(request.getParameter("number2"));
		int number3 = Integer.valueOf(request.getParameter("number3"));
		int year = Integer.valueOf(request.getParameter("year"));
		int month = Integer.valueOf(request.getParameter("month"));
		int day = Integer.valueOf(request.getParameter("day"));
		int year2 = Integer.valueOf(request.getParameter("year2"));
		int month2 = Integer.valueOf(request.getParameter("month2"));
		int day2 = Integer.valueOf(request.getParameter("day2"));
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.flightQuery(c1, c2, date, number1, number2, number3,year,month,day,year2,month2,day2);
		if(map.get("t1") == null){
			Map<String , Object> map1 = new HashMap<String, Object>();
			map1.put("Time","网络速度慢，请重新操作！");
			return new ModelAndView("csair/flightQuery2", map1);
		}
		
		long t1 = (long) map.get("t1");
		long t2 = (long) map.get("t2");
		long t3 = System.currentTimeMillis();
		double chuliTime =  ((t3-t2)/1000.0);
		double totleTime = ((t3-t1)/1000.0);
		double nanhangTime = totleTime - chuliTime;
		log.info("南航官网处理用时："+nanhangTime+"s,无障碍处理用时："+chuliTime+"s,总用时："+totleTime+"s");
		map.put("Time", "南航官网处理用时："+nanhangTime+"s,无障碍处理用时："+chuliTime+"s,总用时："+totleTime+"s");
		return new ModelAndView("csair/flightQuery2", map);
	}
	
	
	
	
	/**
	 * 2期
	 * 往返
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "flightQuery2", method = RequestMethod.GET)
	public ModelAndView query2(HttpSession session, HttpServletRequest request) {
		log.info("===================加载往返航班查询页==================");
		String c1 = request.getParameter("c1");
		String c2 = request.getParameter("c2");
		String date = request.getParameter("date");
		String date2 = request.getParameter("date2");
		// log.info(request.getParameter("number1"));
		int number1 = Integer.valueOf(request.getParameter("number1"));
		int number2 = Integer.valueOf(request.getParameter("number2"));
		int number3 = Integer.valueOf(request.getParameter("number3"));
		int year = Integer.valueOf(request.getParameter("year"));
		int month = Integer.valueOf(request.getParameter("month"));
		int day = Integer.valueOf(request.getParameter("day"));
		int year2 = Integer.valueOf(request.getParameter("year2"));
		int month2 = Integer.valueOf(request.getParameter("month2"));
		int day2 = Integer.valueOf(request.getParameter("day2"));
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.flightQuery2(c1, c2, date, date2, number1, number2, number3,year,month,day,year2,month2,day2);

		if(map.get("t1") == null){
			Map<String , Object> map1 = new HashMap<String, Object>();
			map1.put("Time","网络速度慢，请重新操作！");
			return new ModelAndView("csair/flightQuery2", map1);
		}
		long t1 = (long) map.get("t1");
		long t2 = (long) map.get("t2");
		long t3 = System.currentTimeMillis();
		double chuliTime =  ((t3-t2)/1000.0);
		double totleTime = ((t3-t1)/1000.0);
		double nanhangTime = totleTime - chuliTime;
		log.info("南航官网处理用时："+nanhangTime+"s,无障碍处理用时："+chuliTime+"s,总用时："+totleTime+"s");
		map.put("Time", "南航官网处理用时："+nanhangTime+"s,无障碍处理用时："+chuliTime+"s,总用时："+totleTime+"s");
		return new ModelAndView("csair/flightQueryWF", map);
	}

	/**
	 * 单程航班查询日历
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "week", method = RequestMethod.GET)
	@ResponseBody
	public ModelAndView week(HttpSession session, HttpServletRequest request) {
		String id = request.getParameter("w");
		String cf = request.getParameter("cf");
		String dd = request.getParameter("dd");
		String year = request.getParameter("year");
		String month = request.getParameter("month");
		String day = request.getParameter("day");
		String year2 = request.getParameter("year2");
		String month2 = request.getParameter("month2");
		String day2 = request.getParameter("day2");
		Map<String, Object> map = new HashMap<String, Object>();
		CsairImpl webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.flightQueryEx(id,cf,dd,year,month,day,year2,month2,day2);
		return new ModelAndView("csair/flightQuery2", map);
	}
	
	/**
	 * 2期
	 * 往返航班查询日历1
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "week1", method = RequestMethod.GET)
	@ResponseBody
	public ModelAndView week1(HttpSession session, HttpServletRequest request) {
		String id = request.getParameter("w");
		String cf = request.getParameter("cf");
		String dd = request.getParameter("dd");
		String year = request.getParameter("year");
		String month = request.getParameter("month");
		String day = request.getParameter("day");
		String year2 = request.getParameter("year2");
		String month2 = request.getParameter("month2");
		String day2 = request.getParameter("day2");
		String mark = request.getParameter("mark");
		Map<String, Object> map = new HashMap<String, Object>();
		CsairImpl webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.flightQueryEx1(id,cf,dd,year,month,day,year2,month2,day2,mark);
		return new ModelAndView("csair/flightQueryWF", map);
	}
	/**
	 * 2期
	 * 往返航班查询日历2
	 */
	@RequestMapping(value = "week2", method = RequestMethod.GET)
	@ResponseBody
	public ModelAndView week2(HttpSession session, HttpServletRequest request) {
		String id = request.getParameter("w");
		System.out.println("id============>"+id);
		String cf = request.getParameter("cf");
		String dd = request.getParameter("dd");
		String year = request.getParameter("year");
		String month = request.getParameter("month");
		String day = request.getParameter("day");
		String year2 = request.getParameter("year2");
		String month2 = request.getParameter("month2");
		String day2 = request.getParameter("day2");
		String mark = request.getParameter("mark");
		Map<String, Object> map = new HashMap<String, Object>();
		CsairImpl webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.flightQueryEx2(id,cf,dd,year,month,day,year2,month2,day2,mark);
		return new ModelAndView("csair/flightQueryWF", map);
	}

	/**
	 * 航班选择票价
	 * 
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "getLi1", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> getLi1(HttpSession session, HttpServletRequest request) {
		log.info("=================航班选择票价=====================");
		Map<String, Object> map = new HashMap<String, Object>();
		String href = request.getParameter("href");
		CsairImpl webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map.put("reserve", webClient.flightSelection1(href));
		return map;
	}
	

	/**
	 * 航班选择票价
	 * 
	 * @param session
	 * @param request
	 * @return
	 */
//	@RequestMapping(value = "getLi", method = RequestMethod.POST)
//	@ResponseBody
//	public Map<String, Object> getLi(HttpSession session, HttpServletRequest request) {
//		log.info("================航班选择票价==================");
//		Map<String, Object> map = new HashMap<String, Object>();
//		String href = request.getParameter("href");
//		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
//		map.put("lis", webClient.flightSelection(href));
//		return map;
//	}
	
	/**
	 * 退改信息获取焦点
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "tgxx", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> tgxx(HttpSession session, HttpServletRequest request){
		String tgnum = request.getParameter("tgNum");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.tgxx(tgnum);
		return map;
	}
	
	/**
	 * 行李信息获取焦点
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "xlxx", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> xlxx(HttpSession session, HttpServletRequest request){
		String xlnum = request.getParameter("xlNum");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.xlxx(xlnum);
		return map;
	}
	
	/**
	 * 退改/行李信息失去焦点
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "mouseOut", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> tgxxOut(HttpSession session, HttpServletRequest request){
		Map<String, Object> map = new HashMap<String, Object>();
		String tgnum = request.getParameter("tgNum");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.tgxxOut(tgnum);
		return map;
	}

	/**
	 * 点击订票
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "buyButton", method = RequestMethod.POST)
	@ResponseBody
	public boolean getBuyButton(HttpServletRequest request, HttpSession session) {
		log.info("=================执行点击订票方法====================");
		String href = request.getParameter("href");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Boolean b = webClient.getBuyButton(href);
		log.info("返回旅客信息页URL状态===>"+b);
		return b;
	}
	/**
	 * 点击订票
	 * 
	 */
	@RequestMapping(value = "buyButton", method = RequestMethod.GET)
	public ModelAndView getBuyButton() {
		log.info("=================跳转旅客信息页面====================");
		return new ModelAndView("csair/toaddpassenger2");
	}
	/**
	 * 2期
	 * 点击订票
	 * 
	 */
	@RequestMapping(value = "buyButton1", method = RequestMethod.GET)
	public ModelAndView getBuyButton1() {
		log.info("=================跳转旅客信息页面====================");
		return new ModelAndView("csair/toaddpassengerWF");
	}

	/**
	 * 2期
	 * 往返航班第一次选择订票
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "buyButtonFirst", method = RequestMethod.GET)
	public ModelAndView buyButtonFirst(HttpServletRequest request, HttpSession session) {
		log.info("=================执行往返第一次点击订票方法====================");
		String href = request.getParameter("href");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String,Object> map = webClient.buyButtonFirst(href);
		return new ModelAndView("csair/flightInfoWF", map);
	}
	
	/**
	 * 不登录直接购票
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "nologinorder", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> noLoginOrder(HttpSession session, HttpServletRequest request) {
		log.info("=================不登录直接购票====================");
		Map<String, Object> map = new HashMap<String, Object>();
		String href = request.getParameter("href");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.nologinorder(href);
		log.info("返回旅客信息页url状态===>"+map.get("notice"));
		return map;
	}
	/**
	 * 不登录直接购票
	 */
	@RequestMapping(value = "nologinorder", method = RequestMethod.GET)
	public ModelAndView noLoginOrder() {
		log.info("===============不登录直接购票,跳转旅客信息页面===================");
		return new ModelAndView("csair/toaddpassenger2");
	}
	/**
	 * 2期
	 * 不登录直接购票
	 */
	@RequestMapping(value = "nologinorder1", method = RequestMethod.GET)
	public ModelAndView noLoginOrder1() {
		log.info("===============不登录直接购票,跳转旅客信息页面===================");
		return new ModelAndView("csair/toaddpassengerWF");
	}

	/**
	 * 非登录用户选择登录订票
	 * 
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "toLoginBuyButton", method = RequestMethod.POST)
	@ResponseBody
	public CsairReturnValue toLoginBuyButton(HttpSession session, HttpServletRequest request) {
		log.info("=================非登录用户选择登录订票=====================");
		String href = request.getParameter("href");
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		CsairReturnValue returnValue = webClient.tologin(href, username, password);
		if (returnValue.getState() == CS.SUCCESS) {
			session.setAttribute(Csair.USERNAME, returnValue.getUserName());
			session.setAttribute(Csair.LOGINTYPE, returnValue.getLoginType());
			;
		}
		return returnValue;
	}

	@RequestMapping(value = "toaddpassenger2", method = RequestMethod.GET)
	public ModelAndView toaddpassenger2() {
		log.info("=================非登录用户选择登录订票，跳转旅客信息页面====================");
		return new ModelAndView("csair/toaddpassenger2");
	}
	@RequestMapping(value = "toaddpassengerWF", method = RequestMethod.GET)
	public ModelAndView toaddpassengerWF() {
		log.info("=================非登录用户选择登录订票，跳转旅客信息页面====================");
		return new ModelAndView("csair/toaddpassengerWF");
	}

	/**
	 * 非登录用户动态密码登录发送验证码
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "toLoginPhoneYzm", method = RequestMethod.POST)
	@ResponseBody
	public CsairReturnValue toLoginPhoneYzm(HttpServletRequest request, HttpSession session) {
		String href = request.getParameter("href");
		String username = request.getParameter("username");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		CsairReturnValue returnValue = webClient.tologinYzm(href, username);
		return returnValue;
	}

	/**
	 * 非登录用户动态密码登录
	 * 
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "toLoginPhone", method = RequestMethod.POST)
	@ResponseBody
	public CsairReturnValue toLoginPhone(HttpSession session, HttpServletRequest request) {
		String username = request.getParameter("username");
		String vcodeReg = request.getParameter("vcodeReg");
//		log.info("手机:[" + username + "]\n验证码:[" + vcodeReg + "]");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		CsairReturnValue returnValue = webClient.toLoginPhone(username, vcodeReg);
		if (returnValue.getState() == CS.SUCCESS) {
			session.setAttribute("username", username);
		}
		return returnValue;
	}

	/**
	 * 加载旅客信息1
	 * 
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "toaddpassenger", method = RequestMethod.GET)
	public ModelAndView toaddpassenger1(HttpSession session) {
		log.info("====================加载旅客信息========================");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.toaddpassenger();
		return new ModelAndView("csair/addpassenger", map);
	}

	/**
	 * 加载旅客信息页面的旅客信息
	 */
	@RequestMapping(value = "loadFilightInfo", method = RequestMethod.GET)
	public ModelAndView loadFilightInfo(HttpSession session, HttpServletRequest request) {
		log.info("====================加载旅客信息页面的旅客信息========================");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.toaddpassenger();
		return new ModelAndView("csair/flightInfo2", map);
	}
	/**
	 * 2期
	 * 加载旅客信息页面的旅客信息
	 */
	@RequestMapping(value = "loadFilightInfo1", method = RequestMethod.GET)
	public ModelAndView loadFilightInfo1(HttpSession session, HttpServletRequest request) {
		log.info("====================加载旅客信息页面的旅客信息========================");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.toaddpassenger();
		return new ModelAndView("csair/flightInfo2WF", map);
	}

	/**
	 * 添加乘客填写内容
	 * 
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "addpassenger", method = RequestMethod.POST)
	@ResponseBody
	public CsairReturnValue addpassenger(HttpSession session, HttpServletRequest request) {
		log.info("======================添加乘客填写内容==========================");
		String[] ps = request.getParameterValues("p[]");
		// [988#889#undefined#undefined]
		List<Passenger> list = new ArrayList<Passenger>();
		for (int i = 0; i < ps.length; i++) {
			String[] split = ps[i].split("#");
			if (split[1].equals("undefined")) {
				split[1] = "";
			}
			if (split[2].equals("undefined")) {
				split[2] = "";
			}
			if (split[3].equals("undefined")) {
				split[3] = "";
			}
			if (split[4].equals("undefined")) {
				split[4] = "";
			}
			if (split[5].equals("undefined")) {
				split[5] = "";
			}

			Passenger p = new Passenger();
			p.setpType(split[0]);// 类型
			p.setPsgName(split[1]);// 姓名
			p.setpIdType(split[2]);// 证件类型
			p.setpIdCard(split[3]);// 证件号
			p.setpBirthday(split[4]);// 生日
			p.setCarryByName(split[5]);// 携带人姓名
			list.add(p);
//			log.info("p=======>" + p);
		}
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		CsairReturnValue returnValue = webClient.addpassenger(list);
		return returnValue;
	}

	/**
	 * 添加乘客
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "addpassengerloadFilightInfo", method = RequestMethod.GET)
	public ModelAndView addpassengerloadFilightInfo(HttpServletRequest request, HttpSession session) {
		log.info("===================添加乘客=====================");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.addpassengerloadFilightInfo();
		return new ModelAndView("csair/flightInfo2", map);
	}
	/**
	 * 2期
	 * 添加乘客
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "addpassengerloadFilightInfo1", method = RequestMethod.GET)
	public ModelAndView addpassengerloadFilightInfo1(HttpServletRequest request, HttpSession session) {
		log.info("===================添加乘客=====================");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.addpassengerloadFilightInfo();
		return new ModelAndView("csair/flightInfo2WF", map);
	}

	/**
	 * 点击综合险
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "ir0checkBoxloadFilightInfo", method = RequestMethod.GET)
	public ModelAndView checkBoxloadFilightInfo(HttpServletRequest request, HttpSession session) {
		log.info("=================点击综合险======================");
		String checkBoxId = request.getParameter("checkBoxId");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.checkBoxloadFilightInfo(checkBoxId);
		return new ModelAndView("csair/flightInfo2", map);
	}
	/**
	 * 2期
	 * 点击综合险
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "ir0checkBoxloadFilightInfo1", method = RequestMethod.GET)
	public ModelAndView checkBoxloadFilightInfo1(HttpServletRequest request, HttpSession session) {
		log.info("=================点击综合险======================");
		String checkBoxId = request.getParameter("checkBoxId");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.checkBoxloadFilightInfo(checkBoxId);
		return new ModelAndView("csair/flightInfo2WF", map);
	}

	/**
	 * 点击退票险
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "ir1checkBoxloadFilightInfo", method = RequestMethod.GET)
	public ModelAndView ir1checkBoxloadFilightInfo(HttpServletRequest request, HttpSession session) {
		log.info("==================点击退票险======================");
		String checkBoxId = request.getParameter("checkBoxId");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.ir1checkBoxloadFilightInfo(checkBoxId);
		return new ModelAndView("csair/flightInfo2", map);
	}
	/**
	 * 2期
	 * 点击退票险
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "ir1checkBoxloadFilightInfo1", method = RequestMethod.GET)
	public ModelAndView ir1checkBoxloadFilightInfo1(HttpServletRequest request, HttpSession session) {
		log.info("==================点击退票险======================");
		String checkBoxId = request.getParameter("checkBoxId");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.ir1checkBoxloadFilightInfo(checkBoxId);
		return new ModelAndView("csair/flightInfo2WF", map);
	}

	/**
	 * 点击删除
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "delloadFilightInfo", method = RequestMethod.GET)
	public ModelAndView delloadFilightInfo(HttpServletRequest request, HttpSession session) {
		log.info("==================点击删除乘客======================");
		String divId = request.getParameter("divId");
//		log.info("divId===>" + divId);
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.delloadFilightInfo(divId);
		return new ModelAndView("csair/flightInfo2", map);
	}
	/**
	 * 2期
	 * 点击删除
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "delloadFilightInfo1", method = RequestMethod.GET)
	public ModelAndView delloadFilightInfo1(HttpServletRequest request, HttpSession session) {
		log.info("==================点击删除乘客======================");
		String divId = request.getParameter("divId");
//		log.info("divId===>" + divId);
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.delloadFilightInfo(divId);
		return new ModelAndView("csair/flightInfo2WF", map);
	}
	
	/**
	 * 点击常用旅客
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "clickCommonPassenger", method = RequestMethod.POST)
	@ResponseBody
	public CsairReturnValue clickCommonPassenger(HttpServletRequest request, HttpSession session) {
		log.info("===================点击常用旅客=======================");
		String Id = request.getParameter("id");
		log.info("Id=====>" + Id);
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		CsairReturnValue returnValue = webClient.clickCommonPassenger(Id);
		return returnValue;
	}
	/**
	 * 点击常用旅客加载
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "clickCommonPassengerloadFilightInfo", method = RequestMethod.GET)
	public ModelAndView clickCommonPassengerloadFilightInfo(HttpServletRequest request, HttpSession session) {
		log.info("===================点击常用旅客加载=====================");
		// String divId = request.getParameter("divId");
		// String optionValue = request.getParameter("optionValue");
		// log.info("divId=====>"+divId+" "+"optionValue=====>"+optionValue);
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.clickCommonPassengerloadFilightInfo();
		return new ModelAndView("csair/flightInfo2", map);
	}
	
	
	
	/**
	 * 点击常用旅客加载WF
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "clickCommonPassengerWFloadFilightInfo", method = RequestMethod.GET)
	public ModelAndView clickCommonPassengerWFloadFilightInfo(HttpServletRequest request, HttpSession session) {
		log.info("===================点击常用旅客加载=====================");
		// String divId = request.getParameter("divId");
		// String optionValue = request.getParameter("optionValue");
		// log.info("divId=====>"+divId+" "+"optionValue=====>"+optionValue);
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.clickCommonPassengerWFloadFilightInfo();
		return new ModelAndView("csair/flightInfo2WF", map);
	}
	

	/**
	 * 变更人物类型
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "changePtype", method = RequestMethod.POST)
	@ResponseBody
	public CsairReturnValue changePtype(HttpServletRequest request, HttpSession session) {
		log.info("===================变更人物类型=========================");
		String divId = request.getParameter("divId");
		String optionValue = request.getParameter("optionValue");
//		log.info("divId=====>" + divId + "      " + "optionValue=====>" + optionValue);
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		CsairReturnValue returnValue = webClient.changePtype(divId, optionValue);
		return returnValue;
	}
	
	/**
	 * 变更证件类型
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "changeIDtype", method = RequestMethod.POST)
	@ResponseBody
	public CsairReturnValue changeIDtype(HttpServletRequest request, HttpSession session) {
		log.info("===================变更证件类型=======================");
		String divId = request.getParameter("divId");
		String optionValue = request.getParameter("optionValue");
//		log.info("divId=====>" + divId + "      " + "optionValue=====>" + optionValue);
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		CsairReturnValue returnValue = webClient.changeIDtype(divId, optionValue);
		return returnValue;
	}

	/**
	 * 变更人物/证件类型加载
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "changePtypeloadFilightInfo", method = RequestMethod.GET)
	public ModelAndView changePtypeloadFilightInfo(HttpServletRequest request, HttpSession session) {
		log.info("====================变更人物/证件类型加载=====================");
		// String divId = request.getParameter("divId");
		// String optionValue = request.getParameter("optionValue");
		// log.info("divId=====>"+divId+" "+"optionValue=====>"+optionValue);
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.changePtypeloadFilightInfo();
		return new ModelAndView("csair/flightInfo2", map);
	}
	/**
	 * 2期
	 * 变更人物/证件类型加载
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "changePtypeloadFilightInfo1", method = RequestMethod.GET)
	public ModelAndView changePtypeloadFilightInfo1(HttpServletRequest request, HttpSession session) {
		log.info("====================变更人物/证件类型加载=====================");
		// String divId = request.getParameter("divId");
		// String optionValue = request.getParameter("optionValue");
		// log.info("divId=====>"+divId+" "+"optionValue=====>"+optionValue);
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.changePtypeloadFilightInfo();
		return new ModelAndView("csair/flightInfo2WF", map);
	}

	/**
	 * 提交旅客信息
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "submitOrder", method = RequestMethod.POST)
	@ResponseBody
	public CsairReturnValue submitOrder(HttpServletRequest request, HttpSession session) {
		log.info("===================提交旅客信息====================");
		// String[] pTypes = request.getParameterValues("pType");// 人类型
		// String[] psgNames = request.getParameterValues("psgName");// 姓名
		// String[] pIdTypes = request.getParameterValues("pIdType");// 证件类型
		// String[] pIdCards = request.getParameterValues("pIdCard");// 证件号码
		// String[] pBirthdays = request.getParameterValues("pBirthday");// 出生日期
		// String[] carryByNames = request.getParameterValues("carryByName");// 出生日期
		String[] ps = request.getParameterValues("p[]");
		// [988#889#undefined#undefined]
		List<Passenger> list = new ArrayList<Passenger>();
		for (int i = 0; i < ps.length; i++) {
			String[] split = ps[i].split("#");
			Passenger p = new Passenger();
			p.setpType(split[0]);// 类型
			p.setPsgName(split[1]);// 姓名
			p.setpIdType(split[2]);// 证件类型
			p.setpIdCard(split[3]);// 证件号
			p.setpBirthday(split[4]);// 生日
			p.setCarryByName(split[5]);// 携带人姓名
			list.add(p);
//			log.info(p);
		}

		String contact_name = request.getParameter("contact_name");
		log.info("contact_name==>" + contact_name);
		String contact_moblie = request.getParameter("contact_moblie");
		log.info("contact_moblie==>" + contact_moblie);
		String e_mail = request.getParameter("e_mail");
		log.info("e_mail==>" + e_mail);
		String status = request.getParameter("status");
		log.info("status==>" + status);
		String hbh_ = request.getParameter("hbh");
		log.info("hbh_=====>" + hbh_);
		String arrtime_ = request.getParameter("arrtime");
		log.info("arrtime_=====>" + arrtime_);
		String total_ = request.getParameter("total").substring(1);
		log.info("total_=====>" + total_);

		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		// CsairReturnValue returnValue = webClient.passengerInformation(psgName,
		// pIdCard, contact_name, contact_moblie,
		// e_mail, status);

		CsairReturnValue returnValue = webClient.passengerInformation(list, contact_name, contact_moblie, e_mail,
				status);
		Map<String, Object> map1 = new HashMap<String, Object>();
		long t1 = (long) returnValue.getMap().get("t1");
		long t2 = (long) returnValue.getMap().get("t2");
		double chuliTime1 = (t2 - t1)/1000.0;
		map1.put("chuliTime1", chuliTime1);
		log.info("无障碍填写页面信息用时:"+chuliTime1+"s");
		log.info("returnValue.state====>" + returnValue.getState());
		if (returnValue.getState().toString() == "FAIL") {
			long t3 = System.currentTimeMillis();
			double nanhangTime1 = (t3-t2)/1000.0;
			map1.put("nanhangTime1", nanhangTime1);
			log.info("南航处理返回成功用时"+nanhangTime1+"s,开始获取订单号");
			returnValue.setMap1(map1);
			return returnValue;
		}
		Object u = session.getAttribute(Csair.USERNAME);
		log.info("用户=========>" + u);
		if (u != null) {
			long t3 = System.currentTimeMillis();
			double nanhangTime1 = (t3-t2)/1000.0;
			map1.put("nanhangTime1", nanhangTime1);
			log.info("南航处理返回成功用时"+nanhangTime1+"s,开始获取订单号");
			returnValue = checkOrder(webClient,returnValue,hbh_,arrtime_,total_);
			returnValue.setMap1(map1);
		}

		return returnValue;
	}

	/**
	 * 手机发送验证码
	 * 
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "mobilequery", method = RequestMethod.POST)
	@ResponseBody
	public CsairReturnValue mobilequery(HttpServletRequest request, HttpSession session) {
		log.info("==================手机发送验证码====================");
		String username = request.getParameter("username");
		log.info("username=====>" + username);
		String vcodeReg = request.getParameter("vcodeReg");
		log.info("vcodeReg=====>" + vcodeReg);
//		String hbh_ = request.getParameter("hbh");
//		log.info("hbh_=====>" + hbh_);
//		String arrtime_ = request.getParameter("arrtime");
//		log.info("arrtime_=====>" + arrtime_);
//		String total_ = request.getParameter("total").substring(1);
//		log.info("total_=====>" + total_);
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		CsairReturnValue returnValue = webClient.phone(username, vcodeReg);
		log.info("returnValue.state====>" + returnValue.getState());
		if (returnValue.getState() == CS.SUCCESS) {
			session.setAttribute("loginStatus", "true");
			log.info("返回动态登录状态------>"+session.getAttribute("loginStatus"));
			session.setAttribute(Csair.USERNAME, returnValue.getUserName());
			session.setAttribute(Csair.LOGINTYPE, returnValue.getLoginType());
//			long t3 = System.currentTimeMillis();
//			log.info("==============================================================");
//			double nanhangTime1 = (t3-t2)/1000.0;
//			map1.put("nanhangTime1", nanhangTime1);
//			log.info("南航处理返回成功用时"+nanhangTime1+"s,开始获取订单号");
//			returnValue = checkOrder(webClient,returnValue,hbh_,arrtime_,total_);
//			returnValue.setMap1(map1);
		}else{
			session.setAttribute("loginStatus", "false");
			log.info("返回动态登录状态------>"+session.getAttribute("loginStatus"));
		}

		return returnValue;
	}
	
	/**
	 * 对比订单选单号
	 * @param webClient
	 * @param returnValue
	 * @param hbh_
	 * @param arrtime_
	 * @param total_
	 * @return
	 */
	public CsairReturnValue checkOrder(Csair webClient,CsairReturnValue returnValue,String hbh_,String arrtime_,String total_) {
		log.info("==================查询订单列表进行比对======================");
		Map<String, Object> map = new HashMap<String, Object>();
		String hbh = null;
		String arrtime = null;
		String total = null;
		String carrier = null;
		String flightno = null;
		long t1 = System.currentTimeMillis();
		for (int t = 0; t < 25; t++) {
			Map<String, Object> Order = webClient.queryPlaneOrders1();
			List<Map<String, Object>> listOrders = (List<Map<String, Object>>) Order.get("order");
			long t2 = System.currentTimeMillis();
			double nanhangTime2 = (t2 - t1)/1000.0;
			map.put("nanhangTime2", nanhangTime2);
			log.info("处理南航加载订单详情用时"+nanhangTime2+"s");
//			String orderno = (String) listOrders.get(1).get("orderno");
//			returnValue.setOrderNo(orderno);
//			return returnValue;
			 for (int n = 0; n < listOrders.size(); n++) {
			 Map<String, Object> listOrder = listOrders.get(n);
//			 log.ingo(listOrder.toString());
			// String carrier = (String) ((Map<String,Object>)
//			 map.get("seginfo")).get("carrier");
			 Object seginfo = listOrder.get("seginfo");
			 JSONArray json = JSONArray.fromObject(seginfo);
			
			 
			 JSONObject seginfoJson = json.getJSONObject(0);
			 Object seginfo2 = seginfoJson.get("seginfo");
//			 log.ingo("bu=======>"+seginfo2); 
			 if(seginfo2 != null) {
				 JSONArray json2 = JSONArray.fromObject(seginfo2);
				 JSONObject seginfoJson2 = json2.getJSONObject(0);
				 carrier = seginfoJson2.getString("carrier");
				 flightno = seginfoJson2.getString("flightno");
				
				 hbh=carrier+flightno;
				 arrtime = seginfoJson2.getString("arrtime");
				 total = (String) listOrder.get("totalpaymoney");
			 }else {
				 carrier = seginfoJson.getString("carrier");
				 flightno = seginfoJson.getString("flightno");
				
				 hbh=carrier+flightno;
				 arrtime = seginfoJson.getString("arrtime");
				 total = (String) listOrder.get("totalpaymoney");
			 }
			
			 // 与前台参数做对比
			 log.info(hbh+":"+hbh_+" "+arrtime+":"+arrtime_+" "+total+":"+total_);
			 // 比对
//			 if (hbh.equals(hbh_) && arrtime.equals(arrtime_) && total.equals(total_)) {
			 if (hbh_.contains(hbh) && arrtime_.contains(arrtime) && total_.contains(total)) {
				 long t3 = System.currentTimeMillis();
				 double chuliTime2 = (t3 - t2)/1000.0;
				 map.put("chuliTime2", chuliTime2);
				 log.info("获取订单号，无障碍处理用时"+chuliTime2+"s");
				 String orderno = (String) listOrder.get("orderno");
				 returnValue.setOrderNo(orderno);
				 returnValue.setMap(map);
				 return returnValue;
				 }
			 }
			 long t3 = System.currentTimeMillis();
			 double chuliTime2 = (t3 - t2)/1000.0;
			 map.put("chuliTime2", chuliTime2);
			 log.info("获取订单号，无障碍处理用时"+chuliTime2+"s");
			 returnValue.setMap(map);
			 try {
				Thread.sleep(1500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
		return returnValue;
	}
	/**
	 * 2期
	 * 跳转里程兑换页面
	 * @return
	 */
	@RequestMapping(value = "lcExchange",method = RequestMethod.GET)
	public String lcExchange() {
		log.info("==================跳转里程兑换页面===============");
		return ("csair/lcExchange");
	}
	
	/**
	 * 2期
	 * 加载单程里程兑换页
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "lcExchangeList", method = RequestMethod.GET)
	public ModelAndView lcExchangeList(HttpSession session, HttpServletRequest request) {
		log.info("===================加载单程里程兑换询页==================");
		String c1 = request.getParameter("c1");
		String c2 = request.getParameter("c2");
		String date = request.getParameter("date");
		// log.info(request.getParameter("number1"));
		int year = Integer.valueOf(request.getParameter("year"));
		int month = Integer.valueOf(request.getParameter("month"));
		int day = Integer.valueOf(request.getParameter("day"));
		int year2 = Integer.valueOf(request.getParameter("year2"));
		int month2 = Integer.valueOf(request.getParameter("month2"));
		int day2 = Integer.valueOf(request.getParameter("day2"));
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.lcExchangeList(c1, c2, date,year,month,day,year2,month2,day2);
//		if(map.get("t1") == null){
//			Map<String , Object> map1 = new HashMap<String, Object>();
//			map1.put("Time","网络速度慢，请重新操作！");
//			return new ModelAndView("csair/lcExchangeList", map1);
//		}
		
//		long t1 = (long) map.get("t1");
//		long t2 = (long) map.get("t2");
//		long t3 = System.currentTimeMillis();
//		double chuliTime =  ((t3-t2)/1000.0);
//		double totleTime = ((t3-t1)/1000.0);
//		double nanhangTime = totleTime - chuliTime;
//		log.info("南航官网处理用时："+nanhangTime+"s,无障碍处理用时："+chuliTime+"s,总用时："+totleTime+"s");
//		map.put("Time", "南航官网处理用时："+nanhangTime+"s,无障碍处理用时："+chuliTime+"s,总用时："+totleTime+"s");
		return new ModelAndView("csair/lcExchangeList", map);
	}
	/**
	 * 2期
	 * 加载往返里程兑换页
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "lcExchangeList2", method = RequestMethod.GET)
	public ModelAndView lcExchangeList2(HttpSession session, HttpServletRequest request) {
		log.info("===================加载往返里程兑换询页==================");
		String c1 = request.getParameter("c1");
		String c2 = request.getParameter("c2");
		String date = request.getParameter("date");
		String date2 = request.getParameter("date2");
		// log.info(request.getParameter("number1"));
		int year = Integer.valueOf(request.getParameter("year"));
		int month = Integer.valueOf(request.getParameter("month"));
		int day = Integer.valueOf(request.getParameter("day"));
		int year2 = Integer.valueOf(request.getParameter("year2"));
		int month2 = Integer.valueOf(request.getParameter("month2"));
		int day2 = Integer.valueOf(request.getParameter("day2"));
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.lcExchangeList2(c1, c2, date,date2,year,month,day,year2,month2,day2);
		return new ModelAndView("csair/lcExchangeList2", map);
	}
	
	/**
	 * 2期
	 * 里程兑换显示详情
	 * 
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "getDiv1", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> getDiv1(HttpSession session, HttpServletRequest request) {
		log.info("=================里程兑换显示详情（单程）=====================");
		Map<String, Object> map = new HashMap<String, Object>();
		String id = request.getParameter("id");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.getDiv1(id);
		return map;
	}
	/**
	 * 2期
	 * 往返里程兑换显示详情
	 * 
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "getDiv2", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> getDiv2(HttpSession session, HttpServletRequest request) {
		log.info("=================里程兑换显示详情（往返）=====================");
		Map<String, Object> map = new HashMap<String, Object>();
		String id = request.getParameter("id");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.getDiv2(id);
		return map;
	}
	/**
	 * 2期
	 * 里程兑换单程日历
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "lcWeek", method = RequestMethod.GET)
	@ResponseBody
	public ModelAndView lcWeek(HttpSession session, HttpServletRequest request) {
		log.info("==============里程兑换单程日历单程==============");
		String id = request.getParameter("w");
		String cf = request.getParameter("cf");
		String dd = request.getParameter("dd");
		String year = request.getParameter("year");
		String month = request.getParameter("month");
		String day = request.getParameter("day");
		String year2 = request.getParameter("year2");
		String month2 = request.getParameter("month2");
		String day2 = request.getParameter("day2");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.lcExchangeListEx(id,cf,dd,year,month,day,year2,month2,day2);
		return new ModelAndView("csair/lcExchangeList", map);
	}
	/**
	 * 2期
	 * 里程兑换往返日历1
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "lcWeek1", method = RequestMethod.GET)
	@ResponseBody
	public ModelAndView lcWeek1(HttpSession session, HttpServletRequest request) {
		log.info("==============里程兑换单程日历往返1==============");
		String id = request.getParameter("w");
		String cf = request.getParameter("cf");
		String dd = request.getParameter("dd");
		String year = request.getParameter("year");
		String month = request.getParameter("month");
		String day = request.getParameter("day");
		String year2 = request.getParameter("year2");
		String month2 = request.getParameter("month2");
		String day2 = request.getParameter("day2");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.lcExchangeListEx1(id,cf,dd,year,month,day,year2,month2,day2);
		return new ModelAndView("csair/lcExchangeList2", map);
	}
	
	/**
	 * 2期
	 * 里程兑换往返日历2
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "lcWeek2", method = RequestMethod.GET)
	@ResponseBody
	public ModelAndView lcWeek2(HttpSession session, HttpServletRequest request) {
		log.info("==============里程兑换单程日历往返2==============");
		String id = request.getParameter("w");
		String cf = request.getParameter("cf");
		String dd = request.getParameter("dd");
		String year = request.getParameter("year");
		String month = request.getParameter("month");
		String day = request.getParameter("day");
		String year2 = request.getParameter("year2");
		String month2 = request.getParameter("month2");
		String day2 = request.getParameter("day2");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.lcExchangeListEx2(id,cf,dd,year,month,day,year2,month2,day2);
		return new ModelAndView("csair/lcExchangeList2", map);
	}
	
	/**
	 * 2期
	 * 刷新里程兑换航班列表（单程）
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "loadLcFlightInfo", method = RequestMethod.GET)
	@ResponseBody
	public ModelAndView loadLcFlightInfo(HttpSession session, HttpServletRequest request) {
		log.info("==============刷新里程兑换航班列表（单程）==============");
		String LiChengIdBeChecked = request.getParameter("LiChengIdBeChecked");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.loadLcFilightInfo(LiChengIdBeChecked);
		return new ModelAndView("csair/loadLcFlightInfo", map);
	}
	/**
	 * 2期
	 * 刷新里程兑换航班列表（往返）
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "loadLcFlightInfoWF", method = RequestMethod.GET)
	@ResponseBody
	public ModelAndView loadLcFlightInfoWF(HttpSession session, HttpServletRequest request) {
		log.info("==============刷新里程兑换航班列表（往返）==============");
		String LiChengIdBeChecked = request.getParameter("LiChengIdBeChecked");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.loadLcFlightInfoWF(LiChengIdBeChecked);
		return new ModelAndView("csair/loadLcFlightInfoWF", map);
	}
	
	/**
	 * 2期
	 * 里程兑换页面点击下一步（单程）
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "lcExchangeNext", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> lcExchangeNext(HttpSession session,HttpServletRequest request){
		log.info("===============里程兑换页面点击下一步（单程）=================");
		String data_href = request.getParameter("data_href");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.lcExchangeNext(data_href);
		return map;
	}
	/**
	 * 2期
	 * 跳转里程兑换乘客信息页面
	 * @return
	 */
	@RequestMapping(value = "lcPassenger",method = RequestMethod.GET)
	public String lcPassenger() {
		log.info("==================跳转里程兑换乘客信息页面==============");
		return ("csair/lcPassenger");
	}
	/**
	 * 2期 
	 * 加载里程兑换乘客信息页面
	 */
	@RequestMapping(value = "loadLCFilightInfo", method = RequestMethod.GET)
	public ModelAndView loadLCFilightInfo(HttpSession session, HttpServletRequest request) {
		log.info("===================加载里程兑换乘客信息页面========================");
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		Map<String, Object> map = webClient.lcPassenger();
		return new ModelAndView("csair/lcPassengerFlightInfo", map);
	}
	
	
	/**
	 * 2期
	 * 里程兑换乘客信息点击保险
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "baoxiancheckloadLCFilightInfo", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> baoxiancheckloadLCFilightInfo(HttpSession session){
		log.info("===============里程兑换乘客信息点击保险=================");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.baoxiancheckloadLCFilightInfo();
		return map;
	}
	
	/**
	 * 2期
	 * 里程兑换页面点击下一步（往返）
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "lcExchangeNext2", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> lcExchangeNext2(HttpSession session,HttpServletRequest request){
		log.info("===============里程兑换页面点击下一步（往返）=================");
		String data_href1 = request.getParameter("data_href1");
		String data_href2 = request.getParameter("data_href2");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.lcExchangeNext2(data_href1,data_href2);
		return map;
	}
	
	/**
	 * 2期
	 * 旅客信息证件类型变更方法（里程兑换）
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "cardTypeChange", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> cardTypeChange(HttpSession session,HttpServletRequest request){
		log.info("===============旅客信息证件类型变更方法（里程兑换）=================");
		String cardTypeValue = request.getParameter("cardTypeValue");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.cardTypeChange(cardTypeValue);
		return map;
	}
	
	/**
	 * 2期
	 * 可选旅客变更(里程兑换)
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "kxPassengerChange", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> kxPassengerChange(HttpSession session,HttpServletRequest request){
		log.info("===============可选旅客变更（里程兑换）=================");
		String enname = request.getParameter("enname");
		String cardTypeValue = request.getParameter("cardTypeValue");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.kxPassengerChange(enname,cardTypeValue);
		return map;
	}
	
	/**
	 * 2期
	 * 受让人点击发送验证码(里程兑换)
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "lcAssigneeCtrlYzm", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> lcAssigneeCtrlYzm(HttpSession session,HttpServletRequest request){
		log.info("===============受让人点击发送验证码（里程兑换）=================");
		String checkVcodeId = request.getParameter("checkVcodeId");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.lcAssigneeCtrlYzm(checkVcodeId);
		return map;
	}
	
	/**
	 * 2期
	 * 里程受让人校验
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "lcAssigneeCtrlCheck", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> lcAssigneeCtrlCheck(HttpSession session,HttpServletRequest request){
		log.info("===============里程受让人校验=================");
		String code = request.getParameter("code");
		Map<String, Object> map = new HashMap<String, Object>();
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		map = webClient.lcAssigneeCtrlCheck(code);
		return map;
	}
	
	
	
	
	/**
	 * 提交旅客信息（里程兑换）
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "submitLCOrder", method = RequestMethod.POST)
	@ResponseBody
	public CsairReturnValue submitLCOrder(HttpServletRequest request, HttpSession session) {
		log.info("===================提交旅客信息（里程兑换）====================");
		
		String contact_name = request.getParameter("contact_name");
		log.info("contact_name==>" + contact_name);
		String contact_moblie = request.getParameter("contact_moblie");
		log.info("contact_moblie==>" + contact_moblie);
		String e_mail = request.getParameter("e_mail");
		log.info("e_mail==>" + e_mail);
		
		Csair webClient = (CsairImpl) session.getAttribute(Csair.WEBCLIENT);
		
		CsairReturnValue returnValue = webClient.lcPassengerInformation(contact_name, contact_moblie, e_mail);
//		Map<String, Object> map1 = new HashMap<String, Object>();
//		long t1 = (long) returnValue.getMap().get("t1");
//		long t2 = (long) returnValue.getMap().get("t2");
//		double chuliTime1 = (t2 - t1)/1000.0;
//		map1.put("chuliTime1", chuliTime1);
//		log.info("无障碍填写页面信息用时:"+chuliTime1+"s");
		log.info("returnValue.state====>" + returnValue.getState());
		if (returnValue.getState().toString() == "FAIL") {
//			long t3 = System.currentTimeMillis();
//			double nanhangTime1 = (t3-t2)/1000.0;
//			map1.put("nanhangTime1", nanhangTime1);
//			log.info("南航处理返回成功用时"+nanhangTime1+"s,开始获取订单号");
//			returnValue.setMap1(map1);
			return returnValue;
		}
		Object u = session.getAttribute(Csair.USERNAME);
		log.info("用户=========>" + u);
		if (u != null) {
//			long t3 = System.currentTimeMillis();
//			double nanhangTime1 = (t3-t2)/1000.0;
//			map1.put("nanhangTime1", nanhangTime1);
//			log.info("南航处理返回成功用时"+nanhangTime1+"s,开始获取订单号");
			returnValue = checkLCOrder(webClient,returnValue);
//			returnValue.setMap1(map1);
		}

		return returnValue;
	}
	
	/**
	 * 里程兑换查询订单号
	 * @param webClient
	 * @param returnValue
	 * @return
	 */
	public CsairReturnValue checkLCOrder(Csair webClient,CsairReturnValue returnValue) {
		log.info("==================里程兑换查询订单======================");
			Map<String, Object> Order = webClient.queryPlaneOrders1();
			List<Map<String, Object>> listOrders = (List<Map<String, Object>>) Order.get("order");
			 Map<String, Object> listOrder = listOrders.get(0);
			 String orderno = (String) listOrder.get("orderno");
			 returnValue.setOrderNo(orderno);
		
		return returnValue;
	}
	

}
